//  @ Project : GagalPanen
//  @ File Name : harvestsprite.cpp
//  @ Date : 3/9/2011
//  @ Author : Irvan
//
//


#include "harvestsprite.hpp"
#include "spritesconstants.hpp"
#include "gamemaps.hpp"
#include "plantablecell.hpp"
#include "creatures.hpp"

HarvestSprite::HarvestSprite(GameInterface* game) :
    Sprite(game, SpritesConstants::harvestSpriteStartLocationXCoordinate(),
                 SpritesConstants::harvestSpriteStartLocationYCoordinate()) {
  
  return;
}

HarvestSprite::HarvestSprite(GameInterface* game, std::ifstream& is) :
    Sprite(game, is) {
}

void HarvestSprite::save(std::ofstream& os) {
  Sprite::save(os);
}

HarvestSprite::~HarvestSprite() {
  return;
}

void HarvestSprite::resetPosition() {
  setLocation(
          game_->getMaps()->getField()->getCellAt(
          SpritesConstants::harvestSpriteStartLocationXCoordinate(),
          SpritesConstants::harvestSpriteStartLocationYCoordinate()));
  return;
}

bool HarvestSprite::isImportant(Cell* cell) {
  if (!cell->isPlantable()) {
    return false;
  }
  PlantableCell* pc = (PlantableCell*) cell;
  if (game_->getCreatures()->getPlants()->containsPlantAt(pc)) {
    Plant* plant = game_->getCreatures()->getPlants()->getPlantAt(pc);
    return plant->isHarvestable();
  }
  return false;
}

SpriteType HarvestSprite::getType() {
  return kHarvest;
}

std::string HarvestSprite::getViewRep(Direction dir) {
  return SpritesConstants::getHarvestSpriteRep(dir);
}

ActionType HarvestSprite::getActionType() {
  return kActionHarvestAndSell;
}
